AS=/usr/local/mips-cross/bin/mipsel-elf-as
CC=/usr/local/mips-cross/bin/mipsel-elf-gcc
LD=/usr/local/mips-cross/bin/mipsel-elf-ld
OBJCOPY=/usr/local/mips-cross/bin/mipsel-elf-objcopy
OBJDUMP=/usr/local/mips-cross/bin/mipsel-elf-objdump

CFLAGS=-mips1 -fomit-frame-pointer -nodefaultlibs -nostartfiles -nostdlib -membedded-data -mno-mips16 -fno-builtin -g --std=c99

INCLUDE=-I../../include/

all:
	$(CC) print.c -c $(CFLAGS) $(INCLUDE) -o print.o 
	$(AS) -mips1 bootloader.S -o bootloader.o -EL -g
	$(LD) -mips1 -T ../../lib/default.ld print.o bootloader.o -o print.elf -EL -g
	$(OBJCOPY) -j .startup.bootvec -j .startup -j .rodata -O binary print.elf print.bin
	hexdump -e "1/4 \"%08x\n\"" print.bin -v > print.hex

dump:
	$(OBJDUMP) -j .startup.bootvec -j .startup -S -D print.elf -z

symbols:
	$(OBJDUMP) -t print.elf

sections:
	$(OBJDUMP) -h print.elf

clean:
	rm -f print.bin print.elf print.hex print.o bootloader.o
